package com.eric.code.oauth2.app;

import com.eric.code.oauth2.intercepter.SessionInterceptor;
import com.eric.code.oauth2.intercepter.SuperUserInterceptor;
import com.eric.code.oauth2.model.App;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;

/**
 * Created by eric on 17-3-21.
 */
@Before({SessionInterceptor.class,SuperUserInterceptor.class})
public class AppController extends Controller {

    private AppService srv = AppService.me;

    public void index(){
        setAttr("appPage", srv.paginate(getParaToInt("p", 1)));
        render("index.html");
    }

    public void add(){
        render("add.html");
    }

    public void save(){
        srv.save(getModel(App.class));
        redirect("/app");
    }

    public void del(){
        long id = getParaToLong("id");
        srv.delete(id);
        redirect("/app");
    }


}
